package com.it.LoginSystem.controller;

import com.it.LoginSystem.Pojo.Emp;
import com.it.LoginSystem.service.EmpService;
import com.it.LoginSystem.Pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class RegisterController {
    @Autowired
    private EmpService empService;

    @PostMapping("/api/register")
    public Result register(@RequestBody Emp emp){
        Emp e = empService.register(emp);

        return e != null?Result.success(200,"用户注册成功",e):Result.error(409,"用户名已存在,请尝试使用其他用户名.");
    }

    /**
     * 加密操作
     * @param emp
     * @return
     */
    @PostMapping("/api/registerSSL")
    public Result registerSSL(@RequestBody Emp emp){
        Emp e = empService.registerSSL(emp);

        return e != null?Result.success(200,"用户注册成功",e):Result.error(409,"用户名已存在,请尝试使用其他用户名.");
    }
}
